package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Student;
import com.itheima.pojo.StudentCountData;
import com.itheima.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
    /**
     * 分页查询学生列表
     * @param studentQueryParam
     * @return
     */
    Page<Student> list(StudentQueryParam studentQueryParam);
    /**
     * 删除学生
     * @param ids
     */
    void delete(List<Integer> ids);
    /**
     * 添加学生
     * @param student
     */
    void add(Student student);

    /**
     * 根据Id查询学生
     * 数据回显
     * @param id
     * @return
     */
    Student selectById(Integer id);
    /**
     * 修改学生信息
     * @param student
     */
    void update(Student student);
    /**
     * 查询学生学历数据
     * @return
     */
    List<Map<String, Object>> getStudentDegreeData();


    /**
     * 统计班级学生数量
     * @return
     */
    @Select("""
        select
                    case s.clazz_id
                    when 1 then 'Java163期'
                    when 4 then '前端90期'
                    when 5 then 'JavaEE165期'
                    when 6 then 'JavaEE166期'
                    when 7 then '大数据58期'
                    when 8 then 'JavaEE167期'
                    else '其他'
                    end as ClazzName,
                    count(*) as num
                from student s group by clazz_id
                order by num
""")
    List<StudentCountData> countStudentData();

    /**
     *
     * @param id
     * @param score
     */
    void violate(Integer id, Integer score);
}
